<!DOCTYPE html>

<html xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head th:include="include :: header"></head>
<body class="hold-transition skin-yellow sidebar-mini">
<section class="content-header">
    <h1>排产计划变更查询</h1>
</section>
<section class="content">
    <div class="row">
        <div class="col-xs-12">
            <div class="box">
                <div class="box-header">
                    <form id="queryForm" class="form-horizontal">
                        <div class="row">
                            <div class="form-inline">
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        项目编号
                                    </label>
                                    <label class="control-label">
                                        <input name="propProdNo" class="form-control" type="text" maxlength="255"
                                               value=""
                                               placeholder="请输入项目编号"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        项目名称
                                    </label>
                                    <label class="control-label">
                                        <input name="proName" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入项目名称"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        变更人
                                    </label>
                                    <label class="control-label">
                                        <input name="prpcChaUsr" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入变更人"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        变更原因
                                    </label>
                                    <label class="control-label">
                                        <input name="prpcChaRea" class="form-control" type="text" maxlength="255"
                                               placeholder="请输入变更原因"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">
                                        计划类别
                                    </label>
                                    <label class="control-label">
                                        <select name="prpcCod" class="form-control selectpicker" data-actions-box="true" multiple>
                                            <option selected="selected" style="width:220px"
                                                    th:each="item:${basePlanList}" th:value="${item.badaCod}"
                                                    th:text="${item.badaNam}"></option>
                                        </select>
                                        <input name="prpcCodText" type="hidden" style="display: none"/>
                                    </label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">交货时间</label>
                                    <label class="control-label">
                                        <input type="text" class="form-control datepicker" name="startTime"
                                               readonly="readonly"/>
                                        <span> 至 </span>
                                        <input type="text" class="form-control datepicker" name="endTime"
                                               readonly="readonly"/></label>
                                </div>
                                <div class="form-group margin-bottom-none" style="margin-left:0px;margin-right: 25px;">
                                    <label class="control-label">变更时间</label>
                                    <label class="control-label">
                                        <input type="text" class="form-control datepicker" name="changeStartTime"
                                               readonly="readonly"/>
                                        <span> 至 </span>
                                        <input type="text" class="form-control datepicker" name="changeEndTime"
                                               readonly="readonly"/></label>
                                </div>
                                <button id="btn-search" type="button" class="btn btn-success">
                                    搜索
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
                <div id="toolbar" class="row">
                    <!--                    <button id="btn_getData" class="btn btn-success">获取数据</button>-->
                </div>
                <div class="box-body">
                    <table id="bootstrap-table"></table>
                </div>
            </div>
        </div>
    </div>
</section>
<div th:include="include :: footer"></div>
<script th:inline="javascript">
    let table;
    $(function () {
        /**
         * 加载列表
         */
        loadTable();
        /**
         * 表格搜索
         */
        $("#btn-search").click(function () {
            js.table.search(table);
        });
        /**
         * 获取多选计划名称
         */
        $("#queryForm [name='prpcCod']").change(function () {
            $("#queryForm [name='prpcCodText']").val($("#queryForm [name='prpcCod']").val());
        })
    });

    /**
     * 加载列表
     */
    function loadTable() {
        table = js.table.init({
            url: ctx + "task/changeQuery/list",
            showColumns: true,
            showExport: true,
            columns: [
                {
                    title: '序号', width: '60',
                    formatter: function (value, row, index, field) {
                        var pageSize = table.bootstrapTable('getOptions').pageSize;
                        var pageNumber = table.bootstrapTable('getOptions').pageNumber;
                        return pageSize * (pageNumber - 1) + index + 1;
                    }
                },
                {
                    title: '项目编号', field: 'propProdNo',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }

                    }
                },
                {
                    title: '项目名称', field: 'proName',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }

                    }
                },
                {
                    title: '项目数量', field: 'prodNum',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '计划名称', field: 'prpcNam',
                    formatter: function (value, row, index) {
                        if (value != null) {
                            return value;
                        } else {
                            return '--';
                        }
                    }
                },
                {
                    title: '变更内容',
                    formatter: function (value, row, index) {
                        let changeField = "";
                        switch(row.prpcFieldType){
                            case 1:
                                changeField= "开始时间";
                                break;
                            case 2:
                                changeField= "结束时间";
                                break;
                            default:
                                changeField = "";
                                break;
                        }

                        return '<b>'+changeField+'：【' + row.prpcBef + '】➨【' + row.prpcAft + '】</b>';
                    }
                },
                {
                    title: '变更原因', field: 'prpcChaRea'
                },
                {title: '交货时间', field: 'prodDelDat'},
                {title: '变更人', field: "prpcChaUsr"},
                {title: '变更时间', field: "prpcChaDat"},
                {
                    title: '操作终端信息',
                    formatter: function (value, row, index) {
                        if(row.prpcBrowser.indexOf('<br>')>-1)
                        return "操作系统:" + row.prpcOs + "<br>" + row.prpcBrowser.substring(0,row.prpcBrowser.indexOf('<br>')) + "<br>" + "IP地址：" + row.prpcIp
                    }
                }
            ]
        });
    }
</script>
</body>
</html>